<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateCmsFieldValuesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('cms_field_values')) {
            Schema::create('cms_field_values', function (Blueprint $table) {
                $table->id();
                $table->integer('cms_id')->comment('CMS ID:cms_bases.id');
                $table->integer('field_id')->comment('字段 ID:cms_fields.id');
                $table->string('name', 64)->comment('字段标识名,英文');
                $table->string('label', 64)->comment('字段中文名');
                $table->mediumText('content')->nullable()->comment('字段内容');
                $table->timestamps();
                $table->index('cms_id');
            });
            DB::statement("ALTER TABLE `cms_field_values` comment 'CMS 字段值表'");
        }
        
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cms_field_values');
    }
}
